<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary
  

  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:chart="http://schemas.Kherty.com/office/2007/chart"
  xmlns:chartui="clr-namespace:OpenLS.Chart.UI"
  xmlns:drawing2="clr-namespace:OpenLS.Drawing.UI;assembly=OpenLS.Drawing.UI"
  xmlns:Internals="clr-namespace:OpenLS.Chart.UI.Internals"  
  x:Class="OpenLS.Chart.UI.ScatterSeriesResources"
    >
  <ResourceDictionary.MergedDictionaries>
    <chartui:ChartHelperResources/>
  </ResourceDictionary.MergedDictionaries>
  <DataTemplate DataType="{x:Type chart:ScatterSeries}">
        <Grid Name="grid" chartui:SeriesElement.Series="{Binding}" Internals:FormatHelper.HandlesChartCommands="True">
            <Path StrokeThickness="{Binding ShapeProperties.LineProperties.Width, FallbackValue=3}" 
                  Style="{x:Static chartui:ShapedObjectResources.ShapedElementStyle}"
                  Name="path">
                <Path.Data>
                    <MultiBinding Converter="{x:Static Internals:ChartConverters.ScatterSeriesToGeometryConverter}" >
                        <Binding/>
                        <Binding Path="ActualWidth" ElementName="grid"/>
                        <Binding Path="ActualHeight" ElementName="grid"/>
                        <Binding Path="(chartui:ChartElement.VerticalScaler)" RelativeSource="{RelativeSource Self}"/>
                        <Binding Path="(chartui:ChartElement.HorizontalScaler)" RelativeSource="{RelativeSource Self}"/>
                        <Binding Path="IsSmooth" />
                        <Binding Path="(chartui:ChartElement.Chart).ScatterStyle" RelativeSource="{RelativeSource Self}"/>
                        <Binding Path="(chartui:ChartElement.Observer).Generation" RelativeSource="{RelativeSource Self}"/>
                    </MultiBinding>
                </Path.Data>
                <drawing2:DrawingElement.ShapeProperties>
                    <MultiBinding Converter="{x:Static Internals:ChartConverters.OrSkipNullConverter}">
                        <Binding Path="(chartui:ChartElement.DataPoint).ShapeProperties" RelativeSource="{RelativeSource  Self}" />
                        <Binding Path="(chartui:SeriesElement.Series).ShapeProperties" RelativeSource="{RelativeSource Self}" />
                    </MultiBinding>
                </drawing2:DrawingElement.ShapeProperties>
                <Path.ContextMenu>
                    <ContextMenu>
                        <MenuItem Command="{x:Static chartui:ChartCommands.UnformatDataSeries}"/>
                        <MenuItem Command="{x:Static chartui:ChartCommands.AddTitle}" />
                        <MenuItem Command="{x:Static chartui:ChartCommands.AddLegend}" />
                        <MenuItem Command="{x:Static chartui:ChartCommands.AddDataLabels}"/>
                        <MenuItem Command="{x:Static chartui:ChartCommands.FormatDataLabels}" />
                        <MenuItem Command="{x:Static chartui:ChartCommands.FormatDataSeries}"/>
                    </ContextMenu>
                </Path.ContextMenu>
            </Path>
            <ItemsControl Name="markers" ItemTemplate="{x:Static chartui:MarkerResources.NumericMarkerTemplate}"
                          drawing2:DrawingElement.ShapeProperties="{Binding Marker.ShapeProperties, FallbackValue={x:Null}}"
                          chartui:SeriesElement.Marker="{Binding Marker}"
                          >
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Internals:ScatterPanel 
                            HorizontalOrientation="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.Chart).HorizontalAxis.Orientation}"
                            VerticalOrientation="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.Chart).VerticalAxis.Orientation}"
                            chartui:AxisElement.Minimum="0" chartui:AxisElement.Maximum="20"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
            <ItemsControl Name="dataLabels"
                          ItemsSource="{Binding RelativeSource={RelativeSource Self},Path=(chartui:ChartElement.Observer).Values}"
                          ItemTemplate="{x:Static chartui:DataLabelResources.DataLabelTemplate}"
                        chartui:ChartElement.Observer="{Binding Converter={x:Static Internals:ChartConverters.ScatterSeriesObserverFactory}}"
                          chartui:SeriesElement.DataLabel="{Binding DataLabels}"
                          chartui:SeriesElement.Marker="{Binding Marker}">
                <ItemsControl.ItemContainerStyle>
                    <Style>
                        <Setter Property="Internals:ScatterPanel.Position" Value="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:SeriesElement.DataLabel).Position, Converter={x:Static Internals:ChartConverters.PositionConverter}}"/>
                    </Style>
                </ItemsControl.ItemContainerStyle>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Internals:ScatterPanel 
                            HorizontalOrientation="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.Chart).HorizontalAxis.Orientation}"
                            VerticalOrientation="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.Chart).VerticalAxis.Orientation}"
                            chartui:AxisElement.Minimum="0" chartui:AxisElement.Maximum="20"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>


            </ItemsControl>

        </Grid>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=DataLabels}" Value="{x:Null}">
                <Setter TargetName="dataLabels" Property="ItemsSource" Value="{x:Null}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=ShapeProperties.LineProperties.LineFillProperties}" Value="{x:Null}">
                <Setter Property ="Stroke" TargetName="path">
                    <Setter.Value>
                        <MultiBinding Converter="{x:Static Internals:ChartConverters.PatternConverter}">
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:ChartElement.Style)"/>
                            <Binding Path="Index"/>
                            <Binding RelativeSource="{RelativeSource Self}" Path="(drawing2:DrawingElement.Theme).ColorScheme"/>
                            <Binding Source="debug4"/>
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.Chart).ScatterStyle}" Value="{x:Static chart:ScatterStyle.Marker}">
                <Setter TargetName="markers" Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource Self},Path=(chartui:ChartElement.Observer).Values}" />
                <Setter TargetName="markers" Property="chartui:ChartElement.Observer" Value="{Binding Converter={x:Static Internals:ChartConverters.ScatterSeriesObserverFactory}}"/>
                <Setter TargetName="path" Property="Data" Value="{x:Null}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.Chart).ScatterStyle}" Value="{x:Static chart:ScatterStyle.LineMarker}">
                <Setter TargetName="markers" Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource Self},Path=(chartui:ChartElement.Observer).Values}" />
                <Setter TargetName="markers" Property="chartui:ChartElement.Observer" Value="{Binding Converter={x:Static Internals:ChartConverters.ScatterSeriesObserverFactory}}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.Chart).ScatterStyle}" Value="{x:Static chart:ScatterStyle.SmoothMarker}">
                <Setter TargetName="markers" Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource Self},Path=(chartui:ChartElement.Observer).Values}" />
                <Setter TargetName="markers" Property="chartui:ChartElement.Observer" Value="{Binding Converter={x:Static Internals:ChartConverters.ScatterSeriesObserverFactory}}"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

</ResourceDictionary>